//
//  tmpViewController.m
//  tmp
//
//  Created by Ky on 11. 5. 1..
//  Copyright 2011 서울. All rights reserved.
//

#import "tmpViewController.h"
#import "CategoryView.h"
#import "StreetView.h"

@implementation tmpViewController

@synthesize tmpScroll;
@synthesize tmpImage;
@synthesize tmpButton;
@synthesize btnStreet;
@synthesize locx;
@synthesize locy;
@synthesize btnShop;

- (void)dealloc
{
    [tmpScroll release];
    [tmpImage release];
    [tmpButton release];
    [btnStreet release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{        
    [super viewDidLoad];
    tmpImage.image = [UIImage imageNamed:@"map.png"];
    tmpImage = (UIImageView *)btnStreet.superview;
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return self.tmpImage;
}

- (IBAction)showCategoryView
{
    CategoryView *categoryView = [[CategoryView alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:categoryView animated:YES];
}

- (IBAction)showStreetView
{
    StreetView *streetView = [[StreetView alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:streetView animated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
    NSLog(@"locx : %.0f, locy : %.0f", locx, locy);
    
    if(locx != 0 && locy != 0)
    {
        btnShop = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btnShop.frame = CGRectMake(locx, locy, 10, 10);
        [tmpImage addSubview:btnShop];
    }
}

- (void)viewWillDisappear:(BOOL)animated
{    
    [btnShop removeFromSuperview];
}

- (void)viewDidUnload
{
    [tmpButton release];
    tmpButton = nil;
    [self setTmpButton:nil];
    [btnStreet release];
    btnStreet = nil;
    [self setBtnStreet:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

@end
